package com.xxxx.mysql.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.xxxx.mysql.model.WormLink;

public class WormLinkSqlProvider {

    public String insertSelective(WormLink record) {
        BEGIN();
        INSERT_INTO("worm_link");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getLinkName() != null) {
            VALUES("link_Name", "#{linkName,jdbcType=VARCHAR}");
        }
        
        if (record.getLinkUrl() != null) {
            VALUES("link_url", "#{linkUrl,jdbcType=VARCHAR}");
}

        if (record.getUpperLevel() != null) {
                VALUES("upper_level", "#{upperLevel,jdbcType=VARCHAR}");
                }
        
        if (record.getContent() != null) {
            VALUES("content", "#{content,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_Time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(WormLink record) {
        BEGIN();
        UPDATE("worm_link");
        
        if (record.getLinkName() != null) {
            SET("link_Name = #{linkName,jdbcType=VARCHAR}");
        }
        
        if (record.getLinkUrl() != null) {
            SET("link_url = #{linkUrl,jdbcType=VARCHAR}");
        }
        
        if (record.getUpperLevel() != null) {
            SET("upper_level = #{upperLevel,jdbcType=VARCHAR}");
        }
        
        if (record.getContent() != null) {
            SET("content = #{content,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_Time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=INTEGER}");
        
        return SQL();
    }
}